/**
 * @author qixb.fnst
 */
$(function(){
    $.validator.setDefaults({
        submitHandler: function(form){
            form.submit();
        }
    });
    $.validator.addMethod("alnum", function(value, element){
        return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value);
    }, "只能包括英文字母和数字");
    $("#form").validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parent());
        },
        rules: {
            "username": {
                required: true,
                minlength: 4
            },
            "password": {
                required: true,
                minlength: 4
            },
            "company": {
                required: true,
                minlength: 4
            }
        },
        messages: {
            "username": {
                required: "用户名必填",
                minlength: "用户名长度至少为4"
            },
            "password": {
                required: "密码必填",
                minlength: "密码长度至少为4"
            },
            "company": {
                required: "公司名称必填",
                minlength: "公司名称长度至少为4"
            }
        }
    });
});
